//
//  XLDeviceEntity.h
//  xlinksdklib
//
//  Created by 黄 庆超 on 2016/12/23.
//  Copyright © 2016年 xtmac02. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef enum : UInt8 {
    ConnectStatusConnecting                     =   0b0000,
    ConnectStatusLANConnectSuccessfully         =   0b0001,
    ConnectStatusLANConnectFailed               =   0b0010,
    ConnectStatusWANConnectSuccessfully         =   0b0100,
    ConnectStatusWANConnectFailed               =   0b1000,
    ConnectStatusLANAndWANConnectSuccessfully   =   ConnectStatusLANConnectSuccessfully |
    ConnectStatusWANConnectSuccessfully,
    ConnectStatusLANAndWANConnectFailed         =   ConnectStatusLANConnectFailed |
    ConnectStatusWANConnectFailed
}ConnectStatus;

@interface XLDeviceEntity : NSObject

@property (nonatomic, assign) UInt8     protocolVersion;//协议版本
@property (nonatomic, strong) NSData    *macAddress;    //MAC地址
@property (nonatomic, strong) NSString  *productID;     //企业ID
@property (nonatomic, assign) UInt8     mcuHardVersion; //mcu硬件版本号
@property (nonatomic, assign) UInt16    mcuSoftVersion; //mcu软件版本号
@property (nonatomic, assign) UInt16    listenPort;     //监听端口
@property (nonatomic, assign) UInt16    deviceType;     //设备类型

@property (nonatomic, strong) NSString  *deviceName;    //设备名称
@property (nonatomic, strong) NSNumber  *accessKey;
@property (nonatomic, strong) NSNumber  *subKey;

@property (nonatomic, strong) NSString  *ipAddress;     //IP地址
@property (nonatomic, assign) UInt32    deviceID;       //设备ID

@property (nonatomic, assign) ConnectStatus connectStatus;//连接状态


@property (assign, nonatomic, readonly) bool isConnected; //设备是否连接上
@property (assign, nonatomic, readonly) bool isConnecting;//设备是否正在连接
@property (assign, nonatomic, readonly) bool isLANOnline; //局域网是否在线
@property (assign, nonatomic, readonly) bool isWANOnline; //广域网是否在线

-(instancetype)init;

/**
 *  通过字典还原成设备实体
 *
 *  @param dict 设备字典；字典支持protocol 1格式的字典
 *
 *  @return 设备实体
 */
-(XLDeviceEntity *)initWithDictionary:(NSDictionary *)dic;

/**
 *  将设备属性格式化成字典
 *
 *  @return 设备属性字典
 */
-(NSDictionary *)getDictionaryFormat;


/**
 *  获得Mac地址的字符串形式，
 *
 *  @return 格式：00:00:11:aa:bb:cc
 */
-(NSString *)getMacAddressString;

/**
 *  获得Mac地址的字符串形式
 *
 *  @return 格式：000011AABBCC
 */
-(NSString *)getMacAddressSimple;

@end
